﻿Imports System.Data.OleDb


Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim SqlString As String

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)

        ' most active user

        SqlString = "SELECT top 1 TopicsCount + CommentsCount As TotalCount, Writer FROM CountUserCommentTopicsSum order by  TopicsCount + CommentsCount desc "
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        oleDbConn.Open()
        Dim dr As OleDbDataReader = cmd.ExecuteReader()
        If dr.HasRows Then
            dr.Read()
            If Not IsDBNull(dr("Writer")) Then Lbl_ActiveMember.Text = dr("Writer")
            If Not IsDBNull(dr("TotalCount")) Then Lbl_Count.Text = dr("TotalCount")
        End If

        ' Newest Member
        SqlString = "SELECT top 1 userID, UserName FROM aspnet_users order by userID desc "
        Dim cmdNew As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmdNew.CommandType = CommandType.Text
        Dim drNew As OleDbDataReader = cmdNew.ExecuteReader()
        If drNew.HasRows Then
            drNew.Read()
            If Not IsDBNull(drNew("UserName")) Then Lbl_NewestMember.Text = drNew("UserName")
        End If

    End Sub
End Class